package com.yoda.mall.mysql.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yoda.mall.api.CouponProductCategoryRelationApi;
import com.yoda.mall.model.entity.sms.CouponProductCategoryRelation;
import com.yoda.mall.mysql.mapper.CouponProductCategoryRelationMapper;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class CouponProductCategoryRelationApiImpl implements CouponProductCategoryRelationApi {
    @Autowired
    private CouponProductCategoryRelationMapper couponProductCategoryRelationMapper;

    @Override
    public void addCouponProductCategoryRelation(CouponProductCategoryRelation productCategoryRelation) {
        couponProductCategoryRelationMapper.insert(productCategoryRelation);
    }

    @Override
    public void deleteCouponProductCategoryRelationByCouponId(Long id) {
        LambdaQueryWrapper<CouponProductCategoryRelation> lqw = new LambdaQueryWrapper<>();
        lqw.eq(CouponProductCategoryRelation::getCouponId,id);
        couponProductCategoryRelationMapper.delete(lqw);
    }

    @Override
    public List<CouponProductCategoryRelation> getCouponProductCategoryRelationListByCouponId(Long id) {
        LambdaQueryWrapper<CouponProductCategoryRelation> lqw = new LambdaQueryWrapper<>();
        lqw.eq(CouponProductCategoryRelation::getCouponId,id);
        return couponProductCategoryRelationMapper.selectList(lqw);
    }
}
